package com.xiaoming.service.impl;

import com.xiaoming.service.MethodService;
import org.apache.dubbo.config.annotation.Service;

import java.util.Random;
import java.util.concurrent.TimeUnit;

@Service
public class MethodServiceImpl implements MethodService {
    @Override
    public String methodA() {
        doAction();
        return "method a is finished";
    }

    @Override
    public String methodB() {
        doAction();
        return "method b is finished";
    }

    @Override
    public String methodC() {
        doAction();
        return "method c is finished";
    }

    private void doAction(){
        Random random = new Random();
        int sleepTime = random.nextInt(100);
        try {
            TimeUnit.MILLISECONDS.sleep(sleepTime);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
